<template>
    <div>
        <hd-tab :tabs="tabs"></hd-tab>

        <el-card class="box-card" shadow="never">
            <div slot="header" class="clearfix">
                <span>分配角色</span>
            </div>
            <el-table
                :data="admins"
                border
                size="mini"
                style="width: 100%">
                <el-table-column
                    label="ID"
                    prop="id"
                    width="180">
                </el-table-column>
                <el-table-column
                    label="名称"
                    prop="name"
                    width="180">
                </el-table-column>
                <el-table-column
                    label="手机号"
                    prop="mobile"
                    width="180">
                </el-table-column>
                <el-table-column
                    label="联盟会员"
                    prop="member"
                    width="180">
                </el-table-column>
                <el-table-column
                    label="是否管理员"
                    prop="is_admin">
                </el-table-column>
                <el-table-column
                    #default="{row:admin}"
                    label="角色"
                >
                    <el-tag v-for="(role,index) in admin.roles" class="mx-1"  :key="index" size="mini" type="success">
                        {{ role.title }}
                    </el-tag>
                </el-table-column>
                <el-table-column
                    #default="{row:admin}"
                    label="操作"
                >
                    <el-button-group>
                        <el-button size="mini" type="primary"
                                   @click="$router.push({name:'admin.role.selectroles',params:{id:admin.id}})">
                            分配角色
                        </el-button>
                    </el-button-group>
                </el-table-column>
            </el-table>

        </el-card>
    </div>
</template>

<script>
import tabs from './tabs'

export default {
    route: {name: 'admin.role.syncroles', meta: {title: '角色分配'}},
    data() {
        return {
            tabs,
            admins: [],
            dialogVisible: false,
            roles: [],
        }
    },
    async created() {
        this.admins = await this.axios.get('admin/user/isAdmin')
    },
}
</script>

<style scoped>

</style>
